package bookez.view.bean;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;

import bookez.model.businessobject.BusType;
import bookez.model.service.BusTypeService;

@ManagedBean
@SessionScoped
public class BusTypeBean extends BaseBean {
	
	/*-----------------------------------------------
	 * 	BusTypeBean MessageIDs
	 *----------------------------------------------*/
	
	public static final String NAME_REQUIRED 				= "bookez.view.bean.BusTypeBean.USER_REQUIRED";
	public static final String NAME_EXISTS 					= "bookez.view.bean.BusTypeBean.NAME_EXISTS";
	
	public static final String SEAT_COUNT_RANGE 			= "bookez.view.bean.BusTypeBean.SEAT_COUNT_RANGE";
	public static final String SEAT_COUNT_INCORRECT 		= "bookez.view.bean.BusTypeBean.SEAT_COUNT_INCORRECT";
	
	public static final String SEAT_TYPE_REQUIRED 			= "bookez.view.bean.BusTypeBean.SEAT_TYPE_REQUIRED";
	
	public static final String TYPE_CREATED					= "bookez.view.bean.BusTypeBean.TYPE_CREATED";
	public static final String CANNOT_CREATE				= "bookez.view.bean.BusTypeBean.CANNOT_CREATE";
	
	
	/*-----------------------------------------------
	 * 	BusTypeBean Properties
	 *----------------------------------------------*/
	
	public void setName(String name) { this.name = name; }
	public String getName() { return name; }
	
	public void setSeatType(String seatType) { this.seatType = seatType; }
	public String getSeatType() { return seatType; }

	
	public int getSeatCount() { return seatCount; }
	public void setSeatCount(int seatCount) { this.seatCount = seatCount; }	
	
	public BusTypeService getService() { return this.service; }
	public void setService( BusTypeService value ) { this.service = value; }

	/*-----------------------------------------------
	 * 	Methods
	 *----------------------------------------------*/
	
	public static BusType createBusType( BusTypeBean bean ) { 
		
		BusType type = new BusType();
		type.setName( bean.getName() );
		type.setSeatType( bean.getSeatType() );
		type.setSeatCount( bean.getSeatCount() );
		
		return type;		
	}//end method createBusType
	
	
	public void clear() {
		setName( "" );
		setSeatCount( 0 );
		setSeatType( "" );
	}//end method clear
	
	/*-----------------------------------------------
	 * 	BusTypeBean Instance variables
	 *----------------------------------------------*/

	private String name;
	private String seatType;
	private int seatCount;
	
	@ManagedProperty ( value = "#{busTypeService}")
	private BusTypeService service;
	
	private static final long serialVersionUID = -1454684144247663873L;
}//end class BusTypeBean
